from connect.conn_mysql import Connect

class Detail(Connect):

    def start_time_details(self,start_time):
        if not start_time==None:           
            start_time_sql = '''
            select * from message where start_time=%s
            '''
            result = self.select_all(start_time_sql,(start_time,))
            if result:return {
                        'status':1,
                        'errorCode':None,
                        'errorMsg':None,
                        'resultBody':f'这个时间所有的乘客信息{str(result)}'
                    }
            else:return {
                        'status':-1,
                        'errorCode':404,
                        'errorMsg':'请求失败',
                        'resultBody':'输入时间是非法的'
                    } 

    def start_point_detail(self,start_point):         
        if not start_point==None:
            start_point_sql = '''
            select * from message where start_point=%s
            '''
            result = self.select_all(start_point_sql,(start_point,))
            if result:return {
                        'status':1,
                        'errorCode':None,
                        'errorMsg':None,
                        'resultBody':f'在{start_point}所有的乘客信息{str(result)}'
                    }
            else:return {
                        'status':-1,
                        'errorCode':404,
                        'errorMsg':'请求失败',
                        'resultBody':'请求失非法的'
                    }

    def destination_detail(self,destination):
        if not destination==None:
            destination_sql = '''
            select * from message where destination=%s
            '''
            result = self.select_all(destination_sql,(destination,))
            if result:return {
                        'status':1,
                        'errorCode':None,
                        'errorMsg':None,
                        'resultBody':f'在所有的乘客信息{str(result)}'
                    }
            else:return {
                        'status':-1,
                        'errorCode':404,
                        'errorMsg':'请求失败',
                        'resultBody':'请求失非法的'
                    }

    def pick_up_point_detail(self,pick_up_point):
        if not pick_up_point==None:
            pick_up_point_sql = '''
            select * from message where destination=%s
            '''
            result = self.select_all(pick_up_point_sql,(pick_up_point,))
            if result:return{
                        'status':-1,
                        'errorCode':None,
                        'errorMsg':None,
                        'resultBody':f'在{pick_up_point}上车的客户的所有信息{str(result)}'
                        } 
            else:return{
                        'status':-1,
                        'errorCode':404,
                        'errorMsg':'请求失败',
                        'resultBody':'请求失非法的'
                    }       
        else:
            return '请检查你提交的信息'
       